#version 460
#extension GL_EXT_ray_tracing : require
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require

#include "../Common.glsl"


layout (set = 1, binding = 2) uniform samplerCube cubemapImage;


layout (location = 0) rayPayloadInEXT PathTracePayload hitPayload;


void main()
{
    vec3 environmentMapSample = texture(cubemapImage, gl_WorldRayDirectionEXT).rgb;

    if (hitPayload.depth == 0)
        hitPayload.L = environmentMapSample;
    else
        hitPayload.L = hitPayload.T * environmentMapSample;
}
